# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=google-auth
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.24.0
pkgrel=1
pkgdesc='Google Authentication Library (mingw-w64)'
arch=('any')
url="https://github.com/GoogleCloudPlatform/google-auth-library-python"
license=('Apache')
depends=("${MINGW_PACKAGE_PREFIX}-ca-certificates" "${MINGW_PACKAGE_PREFIX}-python-cachetools" "${MINGW_PACKAGE_PREFIX}-python-pyasn1-modules" "${MINGW_PACKAGE_PREFIX}-python-rsa")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-mock" "${MINGW_PACKAGE_PREFIX}-python-requests" "${MINGW_PACKAGE_PREFIX}-python-flask" "${MINGW_PACKAGE_PREFIX}-python-oauth2client" "${MINGW_PACKAGE_PREFIX}-python-pytest-localserver" "${MINGW_PACKAGE_PREFIX}-python-cryptography" "${MINGW_PACKAGE_PREFIX}-python-freezegun" "${MINGW_PACKAGE_PREFIX}-python-responses" "${MINGW_PACKAGE_PREFIX}-python-pyopenssl")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
options=('!emptydirs')
source=("${_realname}-$pkgver.tar.gz::https://github.com/GoogleCloudPlatform/google-auth-library-python/archive/v$pkgver.tar.gz")
sha256sums=('f37b9cdbe1ce503ff4472a45f9b3fbbe6724f64664573397ac7011b2b3fffbb5')

prepare() {  
  cd "$srcdir"
  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-library-python-${pkgver}" "python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python -m pytest tests || warning "Tests failed"
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
